<template>
  <content-wrapper title="公司资料" :showBackBtn="true">
    <div slot="content" class="wrapper">
      <div v-if="checkStatus === '0'">
        <a-alert message="您的公司信息还未审核,请完善信息提交审核" banner />
        <div class="button-wrapper">
          <a-button type="primary" @click="$commonJs.goPage('companyInfoForm')"
            >完善公司资料</a-button
          >
        </div>
      </div>
      <div v-else-if="checkStatus === '1' || checkStatus === '2'">
        <a-alert message="您的企业信息正在审核中" banner />
        <div class="info">
          <company-info-form :formData="formData"></company-info-form>
        </div>
      </div>
      <div v-else-if="checkStatus === '3' || checkStatus === '4'">
        <a-alert
          :message="
            '您的企业信息由于-' +
              formData.msg +
              '-的原因审核不通过,请重新完善信息提交审核'
          "
          banner
        />
        <div class="button-wrapper">
          <a-button type="primary" @click="$commonJs.goPage('companyInfoForm')"
            >完善公司资料</a-button
          >
        </div>
      </div>
      <div v-else>
        <a-alert message="您的企业信息审核成功" type="success" banner />
        <div class="info">
          <company-info-form :formData="formData"></company-info-form>
        </div>
      </div>
    </div>
  </content-wrapper>
</template>

<script>
import { Alert } from "ant-design-vue";
export default {
  name: "mobile",
  components: {
    contentWrapper: () => import("@/components/contentWrapper/index"),
    aAlert: Alert,
    companyInfoForm: () => import("@/components/companyInfo/disabledForm")
  },
  data() {
    return {
      formData: {
        company_name: "",
        company_intro: "",
        mobile: "",
        base_bank_name: "",
        base_count: "",
        legal_person: "",
        legal_person_id_card: "",
        business_license: "",
        legal_person_id_front: "",
        legal_person_id_back: "",
        company_count: "",
        msg: ""
      }
    };
  },
  methods: {
    getInfo() {
      this.$ajax
        .post(this.$api.getCompanyList)
        .then(res => {
          let status = res.data.status;
          this.$store.dispatch("changeCheckStatus", status.toString());
          this.$store.dispatch("changeValidateMobile", res.data.safemobile);
          if (this.checkStatus === "5" && !this.validateMobile) {
            this.$router.push({ name: "authentication" });
          }
          this.formData = JSON.parse(JSON.stringify(res.data));
        })
        .catch(err => {
          this.$message.error(err);
        });
    }
  },
  created() {
    this.getInfo();
  },
  computed: {
    checkStatus() {
      return this.$store.state.checkStatus;
    },
    validateMobile() {
      return this.$store.state.validateMobile;
    }
  }
};
</script>

<style scoped lang="less">
.info {
  margin-top: 20px;
  padding: 0 16px;
}
.button-wrapper {
  margin-top: 50px;
  text-align: center;
}
</style>
